package service.impl;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
//import org.springframework.messaging.support.MessageBuilder;

import org.springframework.web.bind.annotation.GetMapping;
import service.IMessageProviderService;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @BelongsProject: my
 * @BelongsPackage: service.impl
 * @Author: ji ge
 * @CreateTime: 2024-02-04  12:16
 * @Description: TODO
 * @Version: 1.0
 */
@EnableBinding(Source.class)
public class IMessageProviderServiceImpl implements IMessageProviderService {

    @Resource
    private MessageChannel messageChannel;
    @Override
    public String send() {
        String serial = UUID.randomUUID().toString();
        Message<String> build = MessageBuilder.withPayload(serial).build();
        messageChannel.send(build);
        return serial;
    }
}
